// pages/technicianDetails/technicianDetails.js
import api from '../../../utils/util.js'; // 导入请求类
var app = getApp().globalData;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    navmess:{
      navtitle: "预约确认",
      backhide: 0,
      topheight: 1
    },
    sign: '', // 美容师签名ID
    token: wx.getStorageSync('token'),// 获取token值
    activeBeauticianInfo: {}, // 美容师信息
    skillDisplay: [], // 美容师技能展示
  },
  // 预约确认按钮 this.data.activeBeauticianInfo
  confirmBtn: function(){
    app.activeBeautician = this.data.activeBeauticianInfo;
    wx.navigateBack({delta: 1})
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options);
    let sign = options.BeauticianSign;
    this.setData({sign: sign}); //美容师签名ID
    this.getBeauticianInfo(sign); // 获取美容师的详细信息
  },
  // 根据美容师签名ID拿到美容师信息
  getBeauticianInfo: function(sign){
    var self = this;
    api.post('/mini/appoint/staffDetail',{sign: sign}).then((res)=>{
      let Info = res.result,
          imageList = Info.photoUrls!=""&&Info.photoUrls!=null&&Info.photoUrls.indexOf(',')!=-1?Info.photoUrls.split(','):[Info.photoUrls];
          self.setData({skillDisplay: imageList, activeBeauticianInfo: res.result});
    })
  },
  // 跳转评价页
  toEvaluate: function(){
    wx.navigateTo({url: '/pages/orders/technicianEvaluate/technicianEvaluate?sign='+this.data.sign});
  },
  // 点赞
  give: function(){
    console.log("我被点了");
    let sign = this.data.sign, token = this.data.token;
    api.post('/mini/appoint/goodStaff',{sign: sign,token: token}).then(res=>{
      console.log('点赞回来的数据: ',res);
      if(res.result){
        let good = this.data.activeBeauticianInfo.good;
        good++;
        this.data.activeBeauticianInfo.good = good;
        this.setData({activeBeauticianInfo: this.data.activeBeauticianInfo});
      }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})